<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
	<meta HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>工位实时状态</title>
<style type="text/css">
	@import "../dojo-release-1.5.0/dijit/themes/tundra/tundra.css";
	@import "../dojo-release-1.5.0/dojo/resources/dojo.css";
	@import "../dojo-release-1.5.0/dojox/grid/resources/tundraGrid.css";
</style>
<script type="text/javascript" src="../dojo-release-1.5.0/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="../framework/uiutil.js"></script>
<script type="text/javascript">
function refresh(){
	dojo.xhrGet({
		 url:"../bkgrd/getAllRealtimeWorkayState.do",
		 encoding : 'UTF-8',
		 preventCache:true,
		 handleAs:"json",
		 load:function(response){
			if(response == ""){
				return;
			}
			displayResult(response);
		 }
	});
}

function toTimeStr(datelong){
	var dt = new Date(datelong);
	return dt.getHours()+":"+dt.getMinutes();
}

function displayResult(response){
	for(var i in response){
		var item = response[i];
		var total = item["success"] + item["fail"];
		var timeInterval = item["updateTime"] - item["loginTime"];
		item["succRate"] = (item["success"]*100 / total).toFixed(2)+"%";
		item["loginTime"] = toTimeStr(item["loginTime"]);
		item["updateTime"] = toTimeStr(item["updateTime"]);
		item["repeatRate"] = (item["repeat"]*100 / total).toFixed(2)+"%" ;
		item["speed"] = (item["success"]+item["fail"])+"件@"+ (total/(timeInterval/60000)).toFixed(2)+"件/分钟";
	}
	D.fillTableData("grid",response);
}
</script>

<style type="text/css">
#grid{
	border:1px solid #333;
	width:95%;
	margin:10px;
	height:500px;
	font-size:0.9em;
}
</style>
</head>
<body class="tundra">

<button dojoType="dijit.form.Button" id="query" onclick="refresh()">刷新</button>
<table dojoType="dojox.grid.DataGrid" id="grid"  autoWidth="true">
 <thead>
	<tr>
	     <th field="workbayName">工位编号</th>
	     <th field="loginTime">签到时间</th>
	     <th field="updateTime">更新时间</th>
	     <th field="success">成功数量</th>
	     <th field="fail">失败数量</th>
	     <th field="repeat">复测数量</th>
	     <th field="succRate">成功率</th>
	     <th field="repeatRate">复测率</th>
	     <th field="speed">测试总数/速度</th>
	</tr>
</thead>
</table>
</body>
</html>